package gcosc.fun.hly.fastsso.controller;


import gcosc.fun.hly.fastsso.domain.Bo.PageQuery;
import gcosc.fun.hly.fastsso.domain.SsoRealm;
import gcosc.fun.hly.fastsso.result.Result;
import gcosc.fun.hly.fastsso.result.TableDataInfo;
import gcosc.fun.hly.fastsso.service.ISsoRealmService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.List;

/**
 * 领域
 *
 * @author ruoyi
 * @date 2023-12-30
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/sso/realm")
public class SsoRealmController {

    private final ISsoRealmService iSsoRealmService;

    /**
     * 查询领域列表
     */
    @GetMapping("/list")
    public Result list(SsoRealm bo) {
        return Result.ok(iSsoRealmService.queryList(bo));
    }

    /**
     * 导出领域列表
     */
//    @SaCheckPermission("system:realm:export")
//    @Log(title = "领域", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(SsoRealmBo bo, HttpServletResponse response) {
//        List<SsoRealmVo> list = iSsoRealmService.queryList(bo);
//        ExcelUtil.exportExcel(list, "领域", SsoRealmVo.class, response);
//    }

    /**
     * 获取领域详细信息
     *
     * @param id 主键
     */
    @GetMapping("/{id}")
    public Result<SsoRealm> getInfo(@PathVariable Long id) {
        return Result.ok(iSsoRealmService.queryById(id));
    }

    /**
     * 新增领域
     */
    @PostMapping()
    public Result<Void> add(@RequestBody SsoRealm bo) {
        return Result.ok(iSsoRealmService.insertByBo(bo));
    }

    /**
     * 修改领域
     */
    @PutMapping
    public Result<Void> edit(@RequestBody SsoRealm bo) {
        return Result.ok(iSsoRealmService.updateByBo(bo));
    }

    /**
     * 删除领域
     *
     * @param ids 主键串
     */
    @DeleteMapping("/{ids}")
    public Result<Void> remove(@PathVariable Long[] ids) {
        return Result.ok(iSsoRealmService.deleteWithValidByIds(Arrays.asList(ids), true));
    }
}
